package com.clgk.wechatmall.common.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.clgk.wechatmall.common.ThreadLocals;
import com.clgk.wechatmall.common.constants.Constants;
import com.clgk.wechatmall.manager.entity.ManagerVo;

/**
 * 
 * <P>
 * Description： 预处理拦截器
 * </P>
 * 
 * @author tcloud
 * @version 1.0
 */
public class PreHandleInterceptor extends BaseHandlerInterceptorAdapter
{
    public boolean preHandle(HttpServletRequest request,
            HttpServletResponse response, Object handler) throws Exception
    {
        ThreadLocals.setRequest(request);
        ThreadLocals.setResponse(response);
        long handleId = System.currentTimeMillis();
        ThreadLocals.setHandleId(handleId);
        ManagerVo backUser = (ManagerVo) request.getSession().getAttribute(Constants.SESSION_USER_KEY);
        if (backUser != null)
        {
            ThreadLocals.setBackUser(backUser);
        }
        return super.preHandle(request, response, handler);
    }
}
